#include "bsp_buzzer.h"

#include "main.h"
extern TIM_HandleTypeDef htim12;

void buzzer_init(void)  //蜂鸣器初始化
{
    HAL_TIM_PWM_Start(&htim12,TIM_CHANNEL_1);    
}

void buzzer_on(uint16_t setpsc, uint16_t setpwm)  //开启蜂鸣器
{
    __HAL_TIM_PRESCALER(&htim12, setpsc);
    __HAL_TIM_SetCompare(&htim12, TIM_CHANNEL_1, setpwm);

}

void buzzer_off(void)   //关闭蜂鸣器
{
    __HAL_TIM_SetCompare(&htim12,TIM_CHANNEL_1,0);
}
